<template>
  <div>
    <el-dialog
        :title="title"
        :close-on-click-modal="false"
        :visible.sync="centerDialogVisible"
        width="50%"
    >
      <el-form label-position="left" label-width="120px">
        <el-form-item label="案件处理意见">
          <el-input
              style="width: 500px;"
              type="textarea"
              :rows="2"
              placeholder="请输入案件处理意见"
              v-model="handleRemark">
          </el-input>
          <!--          <el-select v-model="node.roleId" placeholder="请选择身份" @change="roleChange">-->
          <!--            <el-option-->
          <!--                v-for="item in roleOptions"-->
          <!--                :key="item.value"-->
          <!--                :label="item.label"-->
          <!--                :value="item.value">-->
          <!--            </el-option>-->
          <!--          </el-select>-->
        </el-form-item>
        <el-form-item label="案件推送人">
          <el-select v-model="pushUserId" placeholder="请选择案件推送人">
            <el-option
                v-for="item in userOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>

      </el-form>
      <span slot="footer" class="dialog-footer">
    <el-button size="mini" @click="centerDialogVisible = false">取 消</el-button>
    <el-button size="mini" type="primary" @click="submitAdd" style="margin-left: 10px;">确 定</el-button>
  </span>
    </el-dialog>
  </div>
</template>
<script>
import api from '@/utils/api';
import {userSelect} from "@/api/userApi";
import {add} from '@/api/caseCollectApi'

export default {
  components: {userSelect, add},
  mounted() {
  },
  data() {
    return {

      centerDialogVisible: false,
      node: {
        roleId: null,
        userId: null,
        parentId: null
      },
      title: '',
      caseId: '',
      handleRemark: '',
      pushUserId: null,
      roleId: null,
      userId: null,
      roleOptions: [],
      userOptions: [],
    }
  },
  methods: {


    roleChange(e) {
      console.log(e)
      const obj = {}
      obj.id = e
      api.userByRoleId(obj).then(data => {
        if (data.code == 200) {
          this.userOptions = data.data
        }
      })
    },
    listUserSelect() {
      const obj = {}
      obj.id = this.$globalUserId
      userSelect(obj).then(data => {
        if (data.code == 200) {
          this.userOptions = data.data
        }
      })
    },
    open(data) {
      this.centerDialogVisible = true
      this.title = data.title
      this.caseId = data.caseId
      this.listUserSelect()
    },
    clear() {
      this.handleRemark = ''
      this.node.parentId = null
    },
    submitAdd() {
      const self = this
      const obj = {}
      obj.userId = this.$globalUserId
      obj.pushUserId = self.pushUserId
      obj.caseId = self.caseId
      obj.handleRemark = self.handleRemark
      add(obj).then((data) => {
        if (data.code == 200) {
          self.$message({
            type: "success",
            message: data.msg,
          });
          self.centerDialogVisible = false;
          self.clear()
          self.$emit("afterSubmit");
        } else {
          self.$message.error(data.msg);
        }
      })
    }
  }
};
</script>
<style scoped>
.el-form-item {
  margin-bottom: 10px;
}

</style>